/**
 * Author:yuiop
 * Date:2022/9/27 19:05
 */
package com.devops.admin.graphql;

import com.devops.admin.po.DOSK8sRelease;
import com.devops.admin.service.DOSK8sReleaseService;
import com.devops.admin.vo.DOSK8sReleaseVo;
import com.devops.admin.vo.DOSReleaseVo;
import com.devops.common.annotation.DOSLog;
import com.devops.constant.DevOpsConstant;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsQuery;
import com.netflix.graphql.dgs.InputArgument;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;


@DgsComponent
public class DOSK8sReleaseDataFetcher {
    @Autowired
    private DOSK8sReleaseService dosK8sReleaseService;
    @DgsQuery
    @DOSLog(description = "根据releaseId查询k8s集群内对应的release详情")
    @RequiresPermissions(value = {DevOpsConstant.RoleCode.LOGIN_USER},logical = Logical.OR)
    public DOSK8sRelease getK8sReleaseInfo(@InputArgument Integer releaseId) {
        return dosK8sReleaseService.getK8sReleaseInfo(releaseId);
    }

    @DgsQuery
    @DOSLog(description = "根据projectId查询k8s集群内对应的项目所有release详情")
    @RequiresPermissions(value = {DevOpsConstant.RoleCode.SUPER_ADMINISTRATOR,DevOpsConstant.RoleCode.ADMINISTRATOR,
            DevOpsConstant.RoleCode.QA_ADMINISTRATOR,DevOpsConstant.RoleCode.TECHNOLOGY_MANAGER},logical = Logical.OR)
    public DOSK8sRelease getK8sProjectReleaseInfo(@InputArgument DOSReleaseVo releaseVo) {
        return dosK8sReleaseService.getK8sProjectReleaseInfo(releaseVo);
    }


    @DgsQuery
    @DOSLog(description = "查询k8s内Resource详情")
    @RequiresPermissions(value = {DevOpsConstant.RoleCode.LOGIN_USER},logical = Logical.OR)
    public DOSK8sRelease getK8sResourceInfo(@InputArgument DOSK8sReleaseVo release){
        return dosK8sReleaseService.getK8sResourceInfo(release);
    }
}
